package org.wishwork.api.product.common;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.wishwork.api.product.common.item.query.CommonProductItemQueryApi;
import org.wishwork.api.product.common.item.query.CommonProductItemQueryRequest;
import org.wishwork.api.product.common.item.query.response.CommonProductItemQueryResponse;
import org.wishwork.api.product.common.query.CommonProductQueryApi;
import org.wishwork.api.product.common.query.CommonProductQueryRequest;
import org.wishwork.api.product.common.query.CommonProductQueryResponse;
import org.wishwork.api.product.common.upload.CommonProductUploadApi;
import org.wishwork.api.product.common.upload.CommonProductUploadRequest;
import org.wishwork.api.product.common.upload.CommonProductUploadResponse;
import org.wishwork.context.Context;

import java.util.List;

/**
 * @description: 普通商品资料
 * @author: WangYX
 * @create: 2022-04-08 17:38
 * @Version: 1.0.0
 **/
public class CommonProductApi {

    private static final Logger log = LoggerFactory.getLogger(CommonProductApi.class);

    private Context context;

    private final CommonProductUploadApi commonProductUploadApi;

    private final CommonProductQueryApi commonProductQueryApi;

    private CommonProductItemQueryApi commonProductItemQueryApi;

    public CommonProductApi(Context context) {
        this.context = context;
        this.commonProductUploadApi = new CommonProductUploadApi(context);
        this.commonProductQueryApi = new CommonProductQueryApi(context);
        this.commonProductItemQueryApi = new CommonProductItemQueryApi(context);
    }

    /**
     * 普通商品资料上传
     *
     * @param list
     * @return
     * @throws Exception
     */
    public CommonProductUploadResponse upload(List<CommonProductUploadRequest> list) throws Exception {
        return this.commonProductUploadApi.business(list);
    }

    /**
     * 普通商品资料查询 （按sku查询）
     *
     * @param commonProductQueryRequest
     * @return
     * @throws Exception
     */
    public List<CommonProductQueryResponse> query(CommonProductQueryRequest commonProductQueryRequest) throws Exception {
        return this.commonProductQueryApi.business(commonProductQueryRequest);
    }

    /**
     * 普通商品查询 （按款查询）
     *
     * @param commonProductItemQueryRequest
     * @return
     * @throws Exception
     */
    public List<CommonProductItemQueryResponse> itemQuery(CommonProductItemQueryRequest commonProductItemQueryRequest) throws Exception {
        return this.commonProductItemQueryApi.business(commonProductItemQueryRequest);
    }

}
